package org.hot100_1;

import org.leetcode.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class leetcode44 {
    public int kthSmallest(TreeNode root, int k) {
        List<Integer> list = new ArrayList<>();
        putTree(root,list);
        return list.get(k-1);
    }
    private void putTree(TreeNode node ,List<Integer> list){
        if (node==null){
            return;
        }

        putTree(node.left,list);
        list.add(node.val);
        putTree(node.right,list);

    }

}
